package com.hencoderplus.demo1;

import android.content.Context;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * hencoderplus
 * Created by lzw on 2018/10/29. 14:38:20
 * 邮箱：632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class CameraView extends View {

    Camera camera= new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
// translate rotate scale skew
{
    camera.rotateX(30);
    camera.setLocation(0,0,Utils.getZForCamera());//-8=-8*72
}
    public CameraView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.translate(100+((int)Utils.dp2Px(100))/2,100+((int)Utils.dp2Px(100))/2);
        camera.applyToCanvas(canvas);
//        canvas.clipRect(-((int) Utils.dp2Px(100)/20,0,(int) Utils.dp2Px(100)/2,(int) Utils.dp2Px(100));
        canvas.translate(-(100+((int)Utils.dp2Px(100))/2),-(100+((int)Utils.dp2Px(100))/2));
        canvas.drawBitmap(Utils.decodeBitmap(getContext(), (int) Utils.dp2Px(100)),100,100,paint);
    }
}
